//
//  ViewController.m
//  筛选框
//
//  Created by songhuipan on 16/6/26.
//  Copyright © 2016年 songhuipan. All rights reserved.
//

#import "ViewController.h"
#import "UIView+Frame.h"
#import "HomeCell.h"
static NSString *const cellId = @"UICollectionViewCell";
@interface ViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>
@property (nonatomic,strong)UICollectionView *collectionView;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
//    self.navigationController.navigationBar.translucent = NO;
    UIView *topView = [[UIView alloc]initWithFrame:CGRectMake(0, 64, self.view.w, 44)];
    topView.backgroundColor = [UIColor redColor];
    [self.view addSubview:topView];
    [self.collectionView registerClass:[HomeCell class] forCellWithReuseIdentifier:cellId];
    [self.view addSubview:self.collectionView];
}
- (UICollectionView *)collectionView {
    if (!_collectionView) {
        UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
        _collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 44+64, self.view.w, self.view.h-44-64) collectionViewLayout:flowLayout];
        flowLayout.itemSize = CGSizeMake(self.view.w, self.view.h-44-64);
        flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        flowLayout.minimumLineSpacing = 0;
        flowLayout.minimumInteritemSpacing = 0;
        _collectionView.pagingEnabled = YES;
        _collectionView.delegate = self;
        _collectionView.dataSource = self;
    }
    return _collectionView;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 10;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    HomeCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellId forIndexPath:indexPath];
    cell.backgroundColor = [UIColor whiteColor];
    return cell;
}
@end













